<?php

namespace App\Entity\Sale;

use ApiPlatform\Core\Annotation\ApiResource;
use App\Base\Annotation\Common;
use App\Entity\Shop\ShopProduct;
use App\Repository\Sale\SaleMiaoProductRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * @ApiResource()
 * @ORM\Entity(repositoryClass=SaleMiaoProductRepository::class)
 */
class SaleMiaoProduct
{
    /**
     * @Common(cnName="#",listType="text",editType="text")
     * @Groups({"sale"})
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @Common(cnName="活动场次",listType="text",editType="entity",width="200")
     * @Groups({"sale"})
     * @ORM\ManyToOne(targetEntity=SaleMiao::class, inversedBy="list")
     * @ORM\JoinColumn(nullable=false)
     */
    private $miao;

    /**
     * @Common(cnName="产品",listType="text",editType="entity",width="")
     * @Groups({"sale"})
     * @ORM\ManyToOne(targetEntity=ShopProduct::class)
     * @ORM\JoinColumn(nullable=false)
     */
    private $product;

    /**
     * @Common(cnName="X人在抢购",listType="text",editType="text")
     * @Groups({"sale"})
     * @ORM\Column(type="float", nullable=true)
     */
    private $numSell;

    /**
     * @Common(cnName="限量供应",listType="text",editType="text")
     * @Groups({"sale"})
     * @ORM\Column(type="float", nullable=true)
     */
    private $numMax;

    /**
     * @Common(cnName="是否上架",listType="text",editType="switch")
     * @Groups({"sale"})
     * @ORM\Column(type="boolean")
     */
    private $status = true;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getMiao(): ?SaleMiao
    {
        return $this->miao;
    }

    public function setMiao(?SaleMiao $miao): self
    {
        $this->miao = $miao;

        return $this;
    }

    public function getProduct(): ?ShopProduct
    {
        return $this->product;
    }

    public function setProduct(?ShopProduct $product): self
    {
        $this->product = $product;

        return $this;
    }

    public function getNumSell(): ?float
    {
        return $this->numSell;
    }

    public function setNumSell(?float $numSell): self
    {
        $this->numSell = $numSell;

        return $this;
    }

    public function getNumMax(): ?float
    {
        return $this->numMax;
    }

    public function setNumMax(?float $numMax): self
    {
        $this->numMax = $numMax;

        return $this;
    }

    public function getStatus(): ?bool
    {
        return $this->status;
    }

    public function setStatus(bool $status): self
    {
        $this->status = $status;

        return $this;
    }
}
